package br.unicamp.ic.lis.dbvapi.domain;

import java.io.Serializable;

import javax.persistence.Embeddable;

@Embeddable
public class LogicalVersionPK implements Serializable {

	private static final long serialVersionUID = 4137615266090639690L;

	private long oid;
	private long dbvid;

	public LogicalVersionPK() {

	}

	public LogicalVersionPK(long oid, long dbvid) {
		this.oid = oid;
		this.dbvid = dbvid;
	}

	public LogicalVersionPK(MultiversionObject multiVersionObjectId, DBV dbv) {
		this(multiVersionObjectId.getId(), dbv.getId());
	}

	public long getOid() {
		return oid;
	}

	public void setOid(long oid) {
		this.oid = oid;
	}

	public long getDbvid() {
		return dbvid;
	}

	public void setDbvid(long dbvid) {
		this.dbvid = dbvid;
	}

	@Override
	public String toString() {
		return "LogicalVersionPK [oid=" + oid + ", dbvid=" + dbvid + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (dbvid ^ (dbvid >>> 32));
		result = prime * result + (int) (oid ^ (oid >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		LogicalVersionPK other = (LogicalVersionPK) obj;
		if (dbvid != other.dbvid) {
			return false;
		}
		if (oid != other.oid) {
			return false;
		}
		return true;
	}

}
